﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using LanzhouBeefNoodles.Models;
using LanzhouBeefNoodles.ViewModels;
using Microsoft.AspNetCore.Mvc;

namespace LanzhouBeefNoodles.wwwroot.contollers
{
    //[Route("[Controller]/[Action]")]
    public class HomeController : Controller
    {

        private INoodleRepository _noodleRepository;
        private IFeedbackRepository _feedbackRepository;

        public HomeController(INoodleRepository noodleRepository, IFeedbackRepository feedbackRepository)
        {
            _noodleRepository = noodleRepository;
            _feedbackRepository = feedbackRepository;
        }
        public IActionResult Index()
        {
            //var noodles=_noodleRepository.GetAllNoodles();
            HomeViewModel homeViewModel = new HomeViewModel() {
                Feedbacks = _feedbackRepository.GetAllFeedbacks().ToList(),
                Noodles = _noodleRepository.GetAllNoodles().ToList()
            };
            return View(homeViewModel);
        }

        public IActionResult Detail(int id) {
            return View(_noodleRepository.GetNoodleById(id));
        }
   
        public String About()
        {
            return "Hello From About";
        }
    }
}